<template>
  <div id="root">
    <el-card>
      <h2>接收到的留言</h2>
      <template v-for="employee in employers" :key="employee.username">
        <div class="resume-row">
          <div>
            <img :src="employee.avatarUrl" class="avatar" />
          </div>
          <div>{{ employee.name }}</div>
          <div>
            <el-button
              type="primary"
              @click="
                showChatDialog(
                  employee.username,
                  employee.name,
                  employee.avatarUrl
                )
              "
              >与他沟通</el-button
            >
          </div>
        </div>
      </template>
    </el-card>
  </div>
</template>

<script>
import mitter from '../../../plugins/mitter'
export default {
  data() {
    return {
      employers: [],
    }
  },
  created() {
    this.axios
      .get("/employee/list-have-talk?username=" + sessionStorage.getItem("username"))
      .then((res) => {
        if (res.data.code == 200) {
          this.employers = res.data.data;
        }
      });
  },
  methods: {
    showChatDialog(username, name, avatarUrl) {
      const payload = {
        username: username,
        nickname: name,
        avatarUrl: avatarUrl
      }
      mitter.emit('showChatDialog', payload)
    }
  }
};
</script>

<style scoped>
#root {
  width: 800px;
  margin: 100px auto;
}
.job-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.resume-row {
  display: flex;
  justify-content: space-between;
  flex: 0 0;
  align-items: center;
  padding: 10px;
  background: rgb(235, 235, 235);
  border-radius: 25px;
  margin: 10px 0;
}
.resume-row > div {
  margin-right: 20px;
}
.fontstyle {
  font-weight: bold;
}
.resume-row-mid {
  color: gray;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-left: 20px;
  flex-grow: 1;
}
.avatar {
  width: 80px;
  height: 80px;
  border-radius: 40px;
}
</style>